home *** CD-ROM | disk | FTP | other *** search
- Path: news.magic.mb.ca!techtol!tahir.khawaja
- From: tahir.khawaja@techtol.magic.mb.ca (Tahir Khawaja)
- Date: 30 Jan 96 08:52:00
- Newsgroups: comp.sys.amiga.programmer
- Subject: silly c problem
- Message-ID: <f2c_9601302132@techtol.magic.mb.ca>
- Organization: Techtol FidoGate
-
- #include <stdio.h>
-
- main()
- {
- int num1, num2, res, ope, err;
-
- printf("Please input two number!\n");
- scanf("%d%d", &num1, &num2);
- printf("You entered %d and %d.\n\n", &num1, &num2);
- printf("And now the code for the operation!\n");
- printf("1=Add, 2=Subtract, 3=Multiply, 4=Divide\n");
- scanf("%d", &ope);
- printf("You entered %d.\n\n", &ope);
- err = 1;
- if(ope == 1)
- {
- res = num1 + num2;
- err = 0;
- }
- if(ope == 2)
- {
- res = num1 - num2;
- err = 0;
- }
- if(ope == 3)
- {
- res = num1 * num2;
- err = 0;
- }
- if(ope == 4)
- {
- res = num1 / num2;
- err = 0;
- }
- if(err == 1)
- printf("Wrong Code! Input only number 1 - 4!\n");
- else
- printf("The result is %d %d %d %d\n.", &num1, &num2, &res, &err);
- }
- -------------------------------
-
- pretty simple right?
-
- --------------------------------
- Please input two number!
- 2 2
- You entered 2817020 and 2817016.
-
- And now the code for the operation!
- 1=Add, 2=Subtract, 3=Multiply, 4=Divide
- 1
- You entered 2817008.
-
- The result is 2817020 2817016 2817012 2817004
- ----------------------------------
-
- so what am i doing wrong. i'm an absolute beginner at c but not at
- programming. the books i have don't tell me any different way to do this. im
- compiling w/ 'gcc -noixemul -o math math.c' also pretty simple. do i need to
- #include some more stuff?
-
- bye
-
-
- ---
- Tahir.Khawaja@techtol.magic.mb.ca Paradox Programmer
- Data: 1-204-261-7820 Voice : 1-204-275-2344
- --
- |Fidonet: Tahir Khawaja 1:348/705
- |Internet: tahir.khawaja@techtol.magic.mb.ca
- |
- | Standard disclaimer: The views of this user are strictly his own.
-
-